(function(){"use strict";BX.namespace("BX.Landing.UI.Button");BX.Landing.UI.Button.ColorAction=function(t,o){BX.Landing.UI.Button.EditorAction.apply(this,arguments);this.id=t;this.options=o;if(this.id!=="tableBgColor"){this.layout.classList.add("landing-ui-button-editor-action-color")}const n=BX.Landing.UI.Panel.EditorPanel.getInstance().isOutOfFrame()?window.parent:window;this.colorPicker=new n.BX.Landing.UI.Tool.ColorPicker(this,this.onColorSelected.bind(this));BX.Landing.UI.Button.ColorAction.instances.push(this)};BX.Landing.UI.Button.ColorAction.instances=[];BX.Landing.UI.Button.ColorAction.hideAll=function(){BX.Landing.UI.Button.ColorAction.instances.forEach((function(t){t.colorPicker.hide()}))};BX.Landing.UI.Button.ColorAction.prototype={constructor:BX.Landing.UI.Button.ColorAction,__proto__:BX.Landing.UI.Button.EditorAction.prototype,onClick:function(t){t.preventDefault();t.stopPropagation();var o=BX.Landing.UI.Panel.EditorPanel.getInstance().isFixed()?"fixed":"relative";if(!this.colorPicker.isShown()){this.colorPicker.show(o);if(BX.Landing.UI.Button.ChangeTag.menu){BX.Landing.UI.Button.ChangeTag.menu.close()}}else{this.colorPicker.hide()}},onColorSelected:function(t){if(this.id==="tableTextColor"){this.applyColorInTableCells(t)}if(this.id==="tableBgColor"){this.applyBgInTableCells(t)}this.contextDocument.execCommand(this.id,false,t)},applyColorInTableCells:function(t){var o=Array.from(this.options.setTd);o.forEach((function(o){if(o.nodeType===1){o.style.color=t}}));if(this.options.target==="table"){this.options.table.setAttribute("text-color",t)}BX.Landing.Block.Node.Text.currentNode.onChange(true)},prepareOptionsForApplyColorInTableCells:function(t,o){this.options=o;this.applyColorInTableCells(t)},applyBgInTableCells:function(t){var o=Array.from(this.options.setTd);o.forEach((function(o){if(o.nodeType===1){if(!o.classList.contains("landing-table-col-dnd")&&!o.classList.contains("landing-table-row-dnd")&&!o.classList.contains("landing-table-th-select-all")){o.style.setProperty("background-color",t,"important")}}}));if(this.options.target==="table"){this.options.table.setAttribute("bg-color",t)}BX.Landing.Block.Node.Text.currentNode.onChange(true)},setContextDocument:function(t){BX.Landing.UI.Button.EditorAction.prototype.setContextDocument.apply(this,arguments);this.colorPicker.setContextDocument(t)}}})();
//# sourceMappingURL=color_button.map.js